package ch.bfh.abcmmh.controller.logging;

import java.io.IOException;

import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.FileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;

public class TSLoggingFactory {

	private static int diversiti = 0;
	public static final Logger getFileLogger(String logFileName) {

		FileAppender fileAppender;
		Logger logger = Logger.getLogger(logFileName);
		logger.setLevel(Level.DEBUG);
		try {
			fileAppender = new FileAppender(new SimpleLayout(),
					"logs/"+logFileName+".log");
			logger.addAppender(fileAppender);
		} catch (IOException e) {

			ConsoleAppender consoleAppender = new ConsoleAppender(
					new SimpleLayout());
			logger.addAppender(consoleAppender);
		}
		return logger;

	}

	public static final Logger getConsoleLogger() {
		ConsoleAppender consoleAppender = new ConsoleAppender(
				new SimpleLayout());
		Logger logger = Logger.getLogger("Console"+ diversiti++);
		logger.addAppender(consoleAppender);
		logger.setLevel(Level.DEBUG);
		return logger;

	}
}
